Compiling and Executing C Program

 The Compilation and execution process is shown in the image below

Source code: The file contains C program with declarations, functions and have names with the extension C.

Header files: The file contain library functions and definitions that can be used by the source files. The files will have the extension '.h' Header files may be built-in or user-defined.

Object Code: The compiler produces object code stored in object file usually stored with extension '.obj'

Binary Executable file: The linker links a number of object files to produce binary executable files that can be executed directly. The file usually has the extension '.exe'

The steps involved in compiling and executing a C program are:

  1. Creating source code
  2. Compiling source code
  3. Linking the program with C library functions
  4. Executing the program


Creating the Source code:

The file contains C program with declarations, functions, and have names with the extension '.c'. The file is created using any text editors and the source code must follow the C programming rules.

Compiling the Source code:

The first stage if compilation is called preprocessing. In this stage, lines with a '#' character are interpreted by the preprocessor as preprocessor commands. In this stage, the preprocessed code is translated to a form that is suitable for execution by a compiler. If there is no syntax error compilation process produces object code usually stored with extension '.obj'.

Linking the program:

Program is linked with the included header files which contain library functions and definitions that can be used by the source files. The files will have the extension '.h'. Header files may be built in function or user-defined. This process is executed by linker. The linker links a number of object files to produce a binary  executable files that can be executed directly. The files usually has the extension '.exe'

Executing the Program:

This process will load the executable object code into computer memory and executes the code. During execution the program may require input data. If the data is entered without error the program may produce the desired results. If correct output is not produced, the process has to be repeated from editing the source code.

Compiler: The place where we can write our code and execute. These used to translate the source code into object code. Some of the widely use compilers include:

  • Microsoft(Quick C)
  • Turbo C
  • Dev C/C++
  • Visual Studios
  • Aztec








← Back Next →

Comments

Popular posts from this blog

Wrapper Class

Information Security & Essential Terminology

Information Security Threat Categories